From patchwork Mon Jul 22 17:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 813766 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1986800wro; Mon, 22 Jul 2024 11:01:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdhdZ+90DGRrSST8Tg1q2KQqYW96ZXjEQWwu6Y/wz7MA8i2y2VlMc8NWEQ4OIViI3nJVhQymepihqFqgFVg51h X-Google-Smtp-Source: AGHT+IEWc2yQFX+/5cqK7rAsiFQ6+AYlQwcZMkQF34TcMFQx4KJhEGYBz/iNDTgTp4LQLUmM511d X-Received: by 2002:a17:907:94c8:b0:a77:cbe5:413d with SMTP id a640c23a62f3a-a7a87c85f20mr50257466b.6.1721671319735; Mon, 22 Jul 2024 11:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721671319; cv=none; d=google.com; s=arc-20160816; b=mjM+QDnwySACbUGOuBCxveAzqzCmXzgGCzIFEWoi22bCc42QMZAvL8OUmD49mOTaZM 6cKbN6czXRIrfZk6xcUi3DrtnMjgAJfo3DDXJ5jSeca1oYbYaP1nAsJLrA+tMLmI+qPB lRY49adcCREdxbI8ouYRY21a3r+Drf/7h5UddRy+EG/GMc/iQ5ovweMjSHhJOG9D4MZ2 V3YG8U6mkpyI1IukEI377j4e2bMkKUjqLX6JHK5S8VoFlGVf9VadOF+XKkl+0zQbGIDU 3qOMYQnCh1WDyrGDeeiWHKSIzfy/dBb+pO85v9JfVjDz1On5qAwfednKZxW3YRNS/Hpw k8+A== 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=q6u5JOlmgfqULKcBSJqc1nSNBcsqabkbx6MNcU825Oc=; fh=zCTXWkkv5/TakvhlA2Z9qXpupUTMrD8vBaijpeDh/yI=; b=w1CB7eT82v7mwIAci32hHMrcU3CsZq374Mzwwn0Cwy2OSmbho++qOwAjLH84DByP7f L2wAzGHr2/mQImQtP16b/yau0GtWN/weEUqzZriA4YklGnPmH+Lt7/0PTHcHYhK4Lhjl CW0nTESZIpF9dRfbz133ddn6mOYsFvrWEo3dwXpWYTD1Koa44p5r43oF1kurUafe/reW pHLzvb5ZGCQ8MfiqOjx80BZLzpWrWVRMiBvRohYnCir8M4EOoX7jQW9iFUgCFqh6N29t 3K9iId4OQM1o90fWgDn9H8JjNT0gRWcxSCmWU1KVvOl/siwSckd0jGo/Hh1QdTmah+Dg OeXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qmtMmwZK; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a7a3c993a31si407022166b.1030.2024.07.22.11.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 11:01:59 -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=qmtMmwZK; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 73E5888708; Mon, 22 Jul 2024 19:58:07 +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="qmtMmwZK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 072D788645; Mon, 22 Jul 2024 19:58:04 +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-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) (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 6CD598863B for ; Mon, 22 Jul 2024 19:58:00 +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-x32b.google.com with SMTP id 46e09a7af769-70446231242so2335096a34.1 for ; Mon, 22 Jul 2024 10:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721671079; x=1722275879; 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=q6u5JOlmgfqULKcBSJqc1nSNBcsqabkbx6MNcU825Oc=; b=qmtMmwZKEei+Lyn5ys5VMujHWIKRaEz5DyqHoBOgvl7wX4K9DHA2TQAkzx2k0Sacdr pPym4pY+Ado0aFPCqBhl2jLpChHAMoHuYIfbzg5ikixcvRhYtPrWJqWF0tQpdeyzaHpD O3vZCg4o7cXWgzWXu+/BI0TacWMF5LHkc2nIZ5tpD+V7Zy7Tdi0Pm7EJv3nLbNUCtXrv TggeGM6a+wQzohWJ0LlGK/NZiAje2nYitYdj4d+xdZCfFM17g+Ckgv2XUD18BtwRjYHs hTwcq+QbNBLW18IMUjHvNplfxNCohNW31V+E6sEXlaPHgGx+27HNoF3jZmMl1jfwbo+p K33A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721671079; x=1722275879; 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=q6u5JOlmgfqULKcBSJqc1nSNBcsqabkbx6MNcU825Oc=; b=s1RXj9OfFQxzqmOW36eIZsiGHFzR5neodk0lH+z+/IcCS5udhgWoqNmXqKkZW1FSOr HEmllW81IqSurXLxQWnvKuaN8+YssBKkDATrSRJHBAvxvuaCU9qN3vZGXlUtp83laNgF TtVu09TIwFcTqbqRLzYXsowEcBr3kdj+a6GSJlNmvmFXjlDSt7isaCNLGVkJubFVbjmT SPUwdA0/Z3XJbeM7RlpkZGl9ZU1u8d1/zZQIZDdMh+8vzwhU6zj0CIcyMLMFKJ7yV2bD x8rHJzoXDKGuRghvPn/uwuyfP7hHALY+xthjGG3g11I2tUAoygCXf8hjNoA9jnymxRzK yikA== X-Forwarded-Encrypted: i=1; AJvYcCUISMFE0pANvqPsYqKkfh5E8mqRdUK2KdGVZysH79LfjT2FW500MNjnAj1xYHc93IIECN/pmr2wUH8DsJkIGmS/Osi0Vg== X-Gm-Message-State: AOJu0YyBW36v929m5GMSbOIgzfzehqayYmtwZz5RTW3PXHIwvWfrLJ/b 81n8TJ6Np1wWhQypGsEWzaOJKPsDzW5pi8Av6FblDsgWhHbS58Mjl4qSdtQ/R+k= X-Received: by 2002:a05:6830:2712:b0:703:7777:244f with SMTP id 46e09a7af769-70918099151mr748375a34.2.1721671079189; Mon, 22 Jul 2024 10:57:59 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-708f61b2212sm1622113a34.81.2024.07.22.10.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 10:57:58 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang Cc: Tom Rini , Peng Fan , Jaehoon Chung , 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 v3 24/38] mmc: exynos_dw_mmc: Abstract CLKSEL register Date: Mon, 22 Jul 2024 12:57:26 -0500 Message-Id: <20240722175740.6985-25-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240722175740.6985-1-semen.protsenko@linaro.org> References: <20240722175740.6985-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 --- Changes in v3: - (none) Changes in v2: - (none) 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 4108af47e518..fd2ced3d711d 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -33,6 +33,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 @@ -40,6 +45,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( @@ -115,13 +121,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; @@ -132,7 +139,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); @@ -229,6 +236,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); @@ -322,9 +331,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, + }, { } };