From patchwork Mon Jun 10 01:12:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 802956 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp1735063wro; Sun, 9 Jun 2024 18:16:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV8u0cpphaMeyYa/856qSpzy8qQ+RFX6aKg6Z3YoVaTO/Y34Xi+EsGZk293Hhw14SAFF6jojughATcqJxj08Ygo X-Google-Smtp-Source: AGHT+IGR398eIITgG2kWMgtN+RK4zfBPVLo5eejGcfrXYeubrV6FqqPbgU3HErU2RGtGGs9E2bXB X-Received: by 2002:a2e:7009:0:b0:2ea:ea1c:3872 with SMTP id 38308e7fff4ca-2eaea1c4315mr41788371fa.37.1717982212723; Sun, 09 Jun 2024 18:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717982212; cv=none; d=google.com; s=arc-20160816; b=UxzYK6Jo/XJ29MliolmAbH7+ZfGiOuMwFPuZkChQ7Y8o6le1JVrWvKJqIQwpxFnsar BqcqdP9Oy1YXfXS3ttI2bUUrd7D6N7SDGN22BhzenPMBl5Xje7Ywagj+psmB24XbCKPo /PGkwD9X1Fk/64K1lkho9Mu+Rx7+AXrU9/cYi1BLku7SEC12pgZx6OX6n/saGoCv57qP qIuCi3ObbDtuflXon/Z+Eaz9SRkJ0YhQ3atuxfx9KaYXDaltmbXEbSyUTI5xIBe+EgVX iIpZ5EAfqPDKAzEHsp5/Sp6EiZM0DZIhY2jQesGGKFUr9fi8MESt6qCSb0mnx91tJur0 W4sQ== 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=ev16xAcSMFowWept2qugSzFkmqI5xwf3UD/q8/LjRVg=; fh=VHd4M/FsZTWRf0qpThupCRH2z1q7X7gQnjNAP3G/gJI=; b=itxpAeRb4QZdrzgRKluM2y2E/s6ah2lnpmHOUHaNEOY8dmvonDHBhZUtAfkmDAqmUv v+Rl58wW2krKbV/cFrjCxcuu+MPCTZTMDFzratYmsq53UTcGhrtaMUXXT1mT7hiOpZqP O/2T69U72M9DIyCzIgQOUM7ypKc78/OsyrSzG6A+O/daOp35BOxYTChPlrqR1yT/dVep rzw6jr0X39QwSe39mKhvyiEXvg+e3XwTP6BCgqXHsatY7BmnH4ms88vqQfK/co4nBANF 8nDEitwbznLwjdg8U6SHikGJqxxC499ik8Nd/a2gXEI83qWRDnmdTk3cQw06mhFVzyAx oKLg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="aV/zZIWF"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae0c56e5si4192697a12.94.2024.06.09.18.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 18:16:52 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="aV/zZIWF"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 129FD88555; Mon, 10 Jun 2024 03:12:51 +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="aV/zZIWF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B39538852E; Mon, 10 Jun 2024 03:12:48 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) (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 850D4884C5 for ; Mon, 10 Jun 2024 03:12:46 +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-ot1-x333.google.com with SMTP id 46e09a7af769-6f9b5bc97baso213354a34.0 for ; Sun, 09 Jun 2024 18:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717981965; x=1718586765; 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=ev16xAcSMFowWept2qugSzFkmqI5xwf3UD/q8/LjRVg=; b=aV/zZIWFWqn4QvTJvCCFWfio+b9dF8yysHaMOmSE+QCwTqGg9SvCbEtk3l/RS5s1jO 7blsAtYNz4SiD43bAQfT1Hc0Ws1tjikAJs5NC1a5MwtWtL/ORQkhNOLDLODcsXBeD203 IURZhusuXaffbMjquRGTR52t4GRPfYstzAMf2bYJmgUMi90tel/UIq5njD9punzz/qf4 dGgPKAcKAgLKviLJf+0W1Q0FvbhoqN2iZDG/aeTOpJbFkReysHj5Ib6HofMOnbvz5XKY jO54xsXGXsnZK7W73AvagULPtilUPNWeSehvUuTdW/7w9NwbKolGr6horHfuNAOlykih Z3PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717981965; x=1718586765; 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=ev16xAcSMFowWept2qugSzFkmqI5xwf3UD/q8/LjRVg=; b=NWGxjZoIaadCxso4f7ZmwpYTxcPTWXdFcCOm5hb8WPXTmtIrt4kRmdFJOIdMkaB2qx kVofuZmZqxJaFns0buVWssRQy292k9Qez4n/ZbvNIITkaEuR2H+N3sgNgJDej5tuTBIP Cq420T7JMaEUsBz2pM+erSvx+dJHzRNpR5GtCtnoEhlktIofrmkdVb1TU5nQyJELwDqp ZOTpgvIYHs7arrbRdO4VA4uiAGyqdXN8d6/g4Iw3XKcrlEXs2fEcmBlerMZZ9pXv1yUZ wqodQRWCDmTGlOyrT0r4+eyuONrSVZjG2UU7ydxyRupjBbbwTEhxMLrHkADgNi4DRziK mdlA== X-Forwarded-Encrypted: i=1; AJvYcCW4ga1NekK/euc7FdIOzhlQvWLrcXYSYff43J2Hd2knLXV47i4gCL/YIrs9B+sZgGHEVMKBbh5MWDk19YhCJh61pQn+Xg== X-Gm-Message-State: AOJu0YwISTFGPPRARAiUtL+D7SRk5t/IheiFnxpe9Fo6J7jTYeOCOy6d axWvXYvhr/RObdvttW095esHj/SS8C/wUfjrNe4OsGNovoUmhCQLZriGqxM9res= X-Received: by 2002:a9d:4d06:0:b0:6f9:5d21:ccb9 with SMTP id 46e09a7af769-6f95d21ccf2mr6874855a34.38.1717981965178; Sun, 09 Jun 2024 18:12:45 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5bad2536b64sm803374eaf.13.2024.06.09.18.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 18:12:44 -0700 (PDT) From: Sam Protsenko To: Tom Rini , Minkyu Kang , Peng Fan , Jaehoon Chung , Simon Glass Cc: 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 v2 25/40] mmc: exynos_dw_mmc: Abstract CLKSEL register Date: Sun, 9 Jun 2024 20:12:11 -0500 Message-Id: <20240610011226.4050-26-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610011226.4050-1-semen.protsenko@linaro.org> References: <20240610011226.4050-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 CLKSEL register offset may vary between different Exynos chips, e.g. on ARM64 vs ARM32 chips. Provide a way to specify its offset value for each compatible instead of hard-coding its value in read/write calls. No functional change. Signed-off-by: Sam Protsenko --- drivers/mmc/exynos_dw_mmc.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index a6e4d76fb25a..901cfc635418 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -34,6 +34,11 @@ struct exynos_mmc_plat { }; #endif +/* Chip specific data */ +struct exynos_dwmmc_variant { + u32 clksel; /* CLKSEL register offset */ +}; + /* Exynos implmentation specific drver private data */ struct dwmci_exynos_priv_data { #ifdef CONFIG_DM_MMC @@ -41,6 +46,7 @@ struct dwmci_exynos_priv_data { #endif struct clk clk; u32 sdr_timing; + const struct exynos_dwmmc_variant *chip; }; static struct dwmci_exynos_priv_data *exynos_dwmmc_get_priv( @@ -116,13 +122,14 @@ static int exynos_dwmci_clksel(struct dwmci_host *host) { struct dwmci_exynos_priv_data *priv = exynos_dwmmc_get_priv(host); - dwmci_writel(host, DWMCI_CLKSEL, priv->sdr_timing); + dwmci_writel(host, priv->chip->clksel, priv->sdr_timing); return 0; } unsigned int exynos_dwmci_get_clk(struct dwmci_host *host, uint freq) { + struct dwmci_exynos_priv_data *priv = exynos_dwmmc_get_priv(host); unsigned long sclk; int8_t clk_div; int err; @@ -133,7 +140,7 @@ unsigned int exynos_dwmci_get_clk(struct dwmci_host *host, uint freq) * clock value to calculate the CLKDIV value. * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1) */ - clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT) + clk_div = ((dwmci_readl(host, priv->chip->clksel) >> DWMCI_DIVRATIO_BIT) & DWMCI_DIVRATIO_MASK) + 1; err = exynos_dwmmc_get_sclk(host, &sclk); @@ -230,6 +237,8 @@ static int exynos_dwmmc_of_to_plat(struct udevice *dev) int err = 0; u32 div, timing[2]; + priv->chip = (struct exynos_dwmmc_variant *)dev_get_driver_data(dev); + #ifdef CONFIG_CPU_V7A const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); @@ -323,9 +332,22 @@ static int exynos_dwmmc_bind(struct udevice *dev) return dwmci_bind(dev, &plat->mmc, &plat->cfg); } +static const struct exynos_dwmmc_variant exynos4_drv_data = { + .clksel = DWMCI_CLKSEL, +}; + +static const struct exynos_dwmmc_variant exynos5_drv_data = { + .clksel = DWMCI_CLKSEL, +}; + static const struct udevice_id exynos_dwmmc_ids[] = { - { .compatible = "samsung,exynos4412-dw-mshc" }, - { .compatible = "samsung,exynos-dwmmc" }, + { + .compatible = "samsung,exynos4412-dw-mshc", + .data = (ulong)&exynos4_drv_data, + }, { + .compatible = "samsung,exynos-dwmmc", + .data = (ulong)&exynos5_drv_data, + }, { } };