From patchwork Thu Jul 25 20:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 814401 Delivered-To: patch@linaro.org Received: by 2002:adf:e641:0:b0:367:895a:4699 with SMTP id b1csp567289wrn; Thu, 25 Jul 2024 13:49:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXmOQHZU0UaYJSfIMTSgWLKs1f+nxuyN1Fj8Ux08uoPgsbgmZ7vjeCN+SS2pqsDnmtDpZ/XAYTR9uG1WneQzbBJ X-Google-Smtp-Source: AGHT+IHEcoMhiZ2hgHZ5uNtKPXWGbuR9RCpGmeDzxQ1OdfUtl/JiaVqFMYalOwbRAc2MXN39E0lO X-Received: by 2002:a2e:9cd3:0:b0:2ec:5685:f061 with SMTP id 38308e7fff4ca-2f03db71aecmr26422671fa.21.1721940578110; Thu, 25 Jul 2024 13:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721940578; cv=none; d=google.com; s=arc-20160816; b=JyI70mX+9q3n63EeAZhWA08w8D3RtPd9mM9x/PRxwhRthfw0GdqEZ8lT+ZT6he/VMz Pa5hkRRZnfMdeNPpL9LSd0BsmN9GyV9NnB9M8yZuPiUU65FUHuWXyTxGkPleCxfk4gfG kmAhV6/2rVlfVbEoOWDHsLTDsieuAFFf9l4covWASz7LsO8vq5jEOiysRhfgK8XM56rK xTv8luj+6v7Ay6FwEzLAnppUtitJ8Ex2+TdTo++8jhyFtGkX5sIwSlguvfwznd8v9C+5 jwV9exILpq+Hx8Q8U+O4lgcj33cOufiU1Zjglo7/2wiigxqjtylNXROZLN8GOOwlPprv PgJg== 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=9ZFPb823dbyYcmoeeDpUw9xWqzzl5NwxCUroELGCpog=; fh=Ui++Ezk7VIhDpHir9YhSTF+LdGLsJu/AkQcHkzLryBE=; b=CQ0UVAZfW9Dw2VG6mSaa2Bgoy7hi4JcJRYhmFUiyOq45QNfc6K8SMdPuOj0K4VT56s uH+BGwDXGVQCcYtvyWnxaUo+hgCeNCvqCKBEwiwUC7WN1c46ebjeO85Hz2Y6TQH5xx+3 Omh9fJ3sESLv+BJ3f0/KMJ7BKmu+zBRy9rka+uIE6FQ8xSYCgg8Bg8pxOPp1dU6+stav TWl+Io3cwAyyvIBgPVC9YEYmeuK9f+vo+bgHI+USluOZw2p2Je/UiRt1LKBfjXESpPO6 w8eVXwSivBhVhLoRvL42wRkpQoc9zh9b0wBeRApDk1cF+fZAIyI1QvrvSZ4oPCWA0USv Gbsw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=abqXxXCL; 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 38308e7fff4ca-2f03d152ecasi6208391fa.400.2024.07.25.13.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:49:38 -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=abqXxXCL; 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 5132688792; Thu, 25 Jul 2024 22:45:47 +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="abqXxXCL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 97AB5885CF; Thu, 25 Jul 2024 22:45:42 +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-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) (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 72EDE88570 for ; Thu, 25 Jul 2024 22:45:40 +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-x22a.google.com with SMTP id 5614622812f47-3db145c8010so178589b6e.3 for ; Thu, 25 Jul 2024 13:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721940339; x=1722545139; 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=9ZFPb823dbyYcmoeeDpUw9xWqzzl5NwxCUroELGCpog=; b=abqXxXCL54RI3MTOP1kK2zbKNHroz5jyvbbMrCxtSEOt4Rnsbx36dhX7vrrTGBgdCm tvSWRUwglPMyIM1vkhiucKR4bPE48jjPK2lQHGAZlS3sMbUsObJJppfoJ8DWq2JANKRT l6/oLR3eisAsEsLPcpm0SSxbisRprpBmlBa2G2cYuW/w3+ulEbYxglBV4y862olgEkkb uZmBTAdMLJOwD8L+zz95vYkOiuUAnTsqTyVVlSIX2DV5kG6sFVK1S/SgjSSFUBJ0Km17 aCjH+/mVmYDxXqqShD1cQ8FSv42ANGyBJq/Vk4CSUITg682webjxXI9PBnNU03u5bguj J+Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721940339; x=1722545139; 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=9ZFPb823dbyYcmoeeDpUw9xWqzzl5NwxCUroELGCpog=; b=TgNbuKTqSu5BpqrUJXlm+BaFJO0VPSawDCUrNrlS3BMhH5Qj1jFVl86f5xRw0gfiDs pXUw/5bIznklf1zHIhyeL6njRW284cQmgwzUE8ETjiOSjtXVlSDSA871uP1Ol8vGY6JH bCxT7+ysIhPdRIRGJS2ckDuAfkuaHNGLRX2w4JkDNdnU7ma2qy2tw7sogM3XO+fV9LuW txS6UNwRBFb5ikaKHkA+G7Uxrbql9KABjVcPBacoLJtD+zlWKoQ6++ON1u3e1RmFjsL8 gLLPHbToeaIeQh3Dh43J4UIGq85K/tM+wodQKSAEQny7nqsuL22/69KGE5TwaTDIQf2J TUeA== X-Forwarded-Encrypted: i=1; AJvYcCVReB4qex/rmWm8cSTj9qS1IUaXjKrJrwsL8GN8UExoxfTN7teB6vgvLePzhnW+Y4WC/KZ9XlmdNBbfPxWh0OR5GXQPkg== X-Gm-Message-State: AOJu0YwskXpe5KY0uj9h6WQbuYcXkdTiXfGAC7JeNSUzjgRSsaucpYjQ Kn+L93sB3v7ueBz6X/5Ak1BHtMtg6bfOpxVAicEswC2Wszqma4oLskNcmZO53Uk= X-Received: by 2002:a05:6808:14c7:b0:3d9:ad9d:622f with SMTP id 5614622812f47-3db14125766mr2973491b6e.27.1721940339193; Thu, 25 Jul 2024 13:45:39 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3db1357a2casm426513b6e.56.2024.07.25.13.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:45:38 -0700 (PDT) From: Sam Protsenko To: Jaehoon Chung Cc: Minkyu Kang , Minkyu Kang , Tom Rini , 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 v4 24/38] mmc: exynos_dw_mmc: Abstract CLKSEL register Date: Thu, 25 Jul 2024 15:45:06 -0500 Message-Id: <20240725204520.18134-25-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240725204520.18134-1-semen.protsenko@linaro.org> References: <20240725204520.18134-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 v4: - (none) 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, + }, { } };